//
//  PropertyTypeImageButton.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/7/25.
//

import UIKit
import SnapKit
class PropertyTypeImageButton: View {
    let imageView = UIImageView()
    var titleLabel: ContentLabel = {
        let view = ContentLabel(R.font.interMedium(size: 13))
        view.textAlignment = .center
        view.numberOfLines = 0
        return view
    }()
    
    override func setUpView() {
        self.layer.cornerRadius = Constant.StandardCornerRadius
        //back view
        let backView = View()
        self.addSubview(backView)
        backView.snp.makeConstraints { make in
            make.top.greaterThanOrEqualToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
            make.center.equalToSuperview()
            make.left.equalTo(5)
            make.right.equalTo(-5)
            make.height.greaterThanOrEqualTo(0)
        }
        //image
        backView.addSubview(imageView)
        imageView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.size.equalTo(CGSize(width: 40, height: 40))
            make.centerX.equalToSuperview()
        }
        //title
        backView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(imageView.snp.bottom).offset(5)
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
            make.bottom.equalToSuperview()
        }
        self.setUnSelect()
    }
    //选中
    func setSelect(){
        self.titleLabel.textColor = UIColor(hexStr: "#005D2D")
        self.backgroundColor = UIColor(hexStr: "#005D2D1A")
    }
    //没选中
    func setUnSelect(){
        self.titleLabel.textColor = UIColor(hexStr: "#292D32")
        self.backgroundColor = UIColor(hexStr: "#F5F5F5")
    }
    func setDataInfo(title: String, imageName: String){
        self.titleLabel.text = title
        self.imageView.image = UIImage(named: imageName)
    }
    
}
